import { ResPage, SysParam } from "@/api/interface/index";
import { CANROCNET } from "@/api/config/servicePort";
import http from "@/api";

/**
 * 新增参数
 *
 * @param params 参数表单
 * @returns 返回是否成功
 */
export const addParamApi = (params: SysParam.Form) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-param/addition`, params);
};

/**
 * 编辑参数
 *
 * @param params 参数表单
 * @returns 返回是否成功
 */
export const editParamApi = (params: SysParam.Form) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-param/edit`, params);
};

/**
 * 启用/禁用参数
 *
 * @param params 参数Id
 * @returns 返回是否成功
 */
export const switchEnableParamApi = (params: { id: string }) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-param/enable`, params);
};

/**
 * 删除参数
 *
 * @param params 参数Id
 * @returns 返回是否成功
 */
export const deleteParamApi = (params: { ids: string[] }) => {
  return http.post<boolean>(`${CANROCNET}/api/sys-param/del`, params);
};

/**
 * 获取参数列表
 *
 * @param params 参数查询参数
 * @returns 返回参数列表
 */
export const getParamPageApi = (params: SysParam.PageParams) => {
  return http.get<ResPage<SysParam.Result>>(`${CANROCNET}/api/sys-param/page`, params);
};
